#pragma once

#include "Face.h"
#include "../Utilities/BasicLoader.h"

using namespace MjpegProcessor;

ref class MjpegCamera : Face
{
public:
	void Start(Windows::Foundation::Uri^ uriLeft, Windows::Foundation::Uri^ uriRight);
	void Stop();

internal:
	MjpegCamera(BasicLoader^ loader);
	virtual void Update(GameEngine^ engine) override;
	virtual void Render(_In_ ID3D11DeviceContext *context, _In_ ID3D11Buffer *primitiveConstantBuffer, _In_ bool isFirstPass) override;
	void Render(_In_ ID3D11DeviceContext *context, _In_ ID3D11Buffer *primitiveConstantBuffer, _In_ bool isFirstPass, int eye);

	MjpegDecoder^	m_decoderLeft;
	MjpegDecoder^	m_decoderRight;

	BasicLoader^	m_loader;

private:
	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> textureLeft;
	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> textureRight;

	void UpdateTexture(Windows::Storage::Streams::IBuffer^ buffer, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> *texture);
};
